package com.wtc.exception;

import java.util.Scanner;

/**
 * @author 马可
 * @version 1.0
 * try-catch练习题
 * 2023/5/13
 * IntelliJ IDEA
 */
public class TryCatchExercise01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入：");
        String a = scanner.next();
        boolean chose = true;
        while (chose) {
            try {
                int b = Integer.parseInt(a);
                chose = false;
            } catch (NumberFormatException e) {
                System.out.print("请重新输入：");
                a = scanner.next();
            }
        }
    }
}
